#include <iostream>
#include <vector>

using namespace std;
class Solution 
{
public:
    int foundOnceNumber(vector<int>& arr, int k) 
    {
        int res = 0;
        for (int i = 0; i < 32; i++)
        {
            int sum = 0;
            for (auto e : arr) 
            {
                sum += (1 & (e >> i));
            }
            if (sum % k != 0)
            {
                res += (1 << i);
            }
        }
        return res;
    }
};

int main()
{

    vector<int> arr{ 5,4,1,1,5,1,5 };
    int k = 3;

    Solution xz;
    int n = xz.foundOnceNumber(arr, k);
    cout << n << endl;

	return 0;
}
